<template>
    <div>
      <div class="me_header">
        <div class="me_left">
          <img @click="bac()" :src="'./static/lyl/back.png'" alt="">
          <img :src="avatar" alt="">
          <span>{{user_login}}</span>
        </div>
        <span>相册</span>
        <img :src="'./static/lyl/san.png'" alt="">
      </div>
      <div class="me_content">
        <img :src="photoDat[0]" alt="数据加载失败">
        <ul>
          <li v-for="(item,index) in photoDat" :key="index">
            <img @click="scaleph(index)" :src="item" alt="数据加载失败">
          </li>
        </ul>
      </div>
    </div>
</template>

<script>
  import * as search from "../../../api/search.js"
    export default {
      name: "MePhoto",
      data(){
        return {
          user_login:'',
          avatar:'',
          photoDat:[],
        }
      },
      mounted(){
        //获取用户昵称
        let par = {user_id:this.$store.state.user_id};
        search.userinfo(par).then(res=>{
          console.log('用户昵称',res)
          this.user_login = res.data.user_login;
          this.avatar = res.data.avatar
        });
        //机构或达人 相册
        let parms = {user_id:this.$route.query.id};
        search.userPhoto(parms).then(res=>{
          console.log('相册',res);
          this.photoDat = res.data
        })
      },
      methods:{
        bac(){
          history.go(-1)
        },
        scaleph(i){
          this.$router.push('/photo2/'+this.photoDat.length+'/'+(i+1));
          this.$store.commit('chuan',this.photoDat);
        }
      }
    }
</script>

<style scoped>
  .me_header{
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
  }
  .me_header .me_left{
    display: flex;
    align-items: center;
  }
  .me_header .me_left span{
    font-size: 18px;
    color: #818181;
  }
  .me_header .me_left img:nth-child(1){
    width: 25px;
    height: 40px;
  }
  .me_header .me_left img:nth-child(2){
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 20px;
  }
  .me_header>span{
    font-size: 28px;
    align-self: center;
  }
  .me_header>img:nth-child(3){
    align-self: center;
    width: 60px;
  }
  .me_content>img{
    background: #dcdcdc;
    width: 100%;
    height: 420px;
  }
  .me_content ul{
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
  }
  .me_content ul li{
    box-sizing: border-box;
    width: 50%;
    padding: 0 20px 20px 0;
  }
  .me_content ul li:nth-child(2n+2){
    padding-right: 0;
  }
  .me_content ul li img{
    width: 100%;
    height: 100%;
  }
</style>
